<%--
  Created by IntelliJ IDEA.
  User: MSI-CN
  Date: 2021/1/29
  Time: 22:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<% String path=request.getContextPath(); %>
<% if (session.getAttribute("username")==null){
    response.sendRedirect("index.jsp");
}%>
<html>
<head>
    <title>${newsTitle}</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
</head>
<body>
<div class="container">
    <c:forEach items="${list}" var="item">
        <h1 class="display-4 text-center">${item.ntitle}</h1>
        <p>${item.ncreatdate}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${item.nauthor}</p>
        <hr class="my-4">
        <p>${item.ncontent}</p>
        <p id="niddd" style="display: none">${item.nid}</p>
        <br><br><br>
        <hr class="my-4">
        <br><br><br>
        <h4 class="display-4">评论</h4>
        <br><br><br>
    </c:forEach>
    <div class="card">
        <form id="from1" action="<%=path%>/addcomments" method="post" class="was-validated">
            <div class="card-body">
                <div class="card">
                    <div class="card-body">
                        <div class="mb-3">
                            <label for="validationTextarea">发表一个评论吧~</label>
                            <textarea name="comment" class="form-control is-invalid" id="validationTextarea" placeholder="在这里输入~" required style="resize: none ;"></textarea>
                            <input id="name" type="text" style="display: none" name="nid">
                        </div>
                        <button type="button"  class="btn btn-outline-success">提交</button>
                    </div>
                </div>
            </div>
        </form>
    <c:forEach items="${newsCommentsList}" var="item">
            <div class="card-body">
                <div class="card">
                    <div class="card-header">
                            ${item.nauthor}
                    </div>
                    <div class="card-body">
                        <blockquote class="blockquote mb-0">
                            <p>${item.newsComments}</p>
                        </blockquote>
                    </div>
                </div>
            </div>
    </c:forEach>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js" integrity="sha384-+YQ4JLhjyBLPDQt//I+STsc9iw4uQqACwlvpslubQzn4u2UU2UFM80nGisd026JF" crossorigin="anonymous"></script>
<script>
    $(".btn").click(function () {
        $("#name").val(parseInt($("#niddd").text()));
        let form=$("#from1");
        let text=$("#validationTextarea").val();
        if (text.length==0){

        }else {
            $("#from1").submit();
        }

    });
</script>
</body>
</html>
